<template>
  <el-form ref="form" :model="accMyAccountWallet" :rules="rules" label-width="80px">
    <el-form-item label="企业名称" prop="customerName">
      <el-input v-model="accMyAccountWallet.customerName" maxlength="50" />
    </el-form-item>
    <el-form-item label="账户编码" prop="accountNo">
      <el-input v-model="accMyAccountWallet.accountNo" />
    </el-form-item>
    <el-form-item label="开户行" prop="bankName">
      <el-input v-model="accMyAccountWallet.bankName" maxlength="11" />
    </el-form-item>
    <el-form-item label="钱包金额" prop="amount">
      <el-input v-model="accMyAccountWallet.amount" maxlength="50" />
    </el-form-item>

    <el-form-item>
     <!-- <el-button type="primary" size="mini" @click="submit">保存</el-button>
      <el-button type="danger" size="mini" @click="close">关闭</el-button> -->
    </el-form-item>
  </el-form>
</template>

<script>
import SysUserApi from '@/api/system/UserApi'
import AccMyAccountWalletApi from '@/api/accounting/AccMyAccountWalletApi'
import SysDictValueApi from '@/api/system/DictValueApi'

export default {
 props: {
   user: {
     type: Object,
     default: function() {
       return {}
     }
   }
 },
  data() {
    return {
      options: {
        sexOptions: []
      },
      accMyAccountWallet: {

      },
      // 表单校验
      rules: {
        nickName: [{ required: true, message: '用户昵称不能为空', trigger: 'blur' }],
        email: [
          { required: true, message: '邮箱地址不能为空', trigger: 'blur' },
          { type: 'email', message: '请输入正确的邮箱地址', trigger: ['blur', 'change'] }
        ],
        phone: [
          { required: true, message: '手机号码不能为空', trigger: 'blur' },
          { pattern: /^1[3|4|5|6|7|8|9][0-9]\d{8}$/, message: '请输入正确的手机号码', trigger: 'blur' }
        ]
      }
    }
  },
  created() {
     this.init()
    this.loadOptions()
  },
  methods: {
    init() {
      AccMyAccountWalletApi.findByUserId().then(response => {
        this.accMyAccountWallet = response.data
      })
    },
    loadOptions() {
      SysDictValueApi.list({ dictCode: 'sys_sex_type' }).then(response => {
        this.options.sexOptions = response.data
      })
    },
    submit() {
      this.$refs['form'].validate(valid => {
        if (valid) {
          SysUserApi.updateProfile(this.sysUser).then(response => {
            this.$message.success('修改成功')
          })
        }
      })
    },
    close() {
      this.$store.dispatch('tagsView/delView', this.$route)
      this.$router.push({ path: '/index' })
    }
  }
}
</script>
